package com.iwhalecloud.bss.kite.cucc.service.custview.userinfo.supplier;

import com.iwhalecloud.bss.kite.common.util.KiteMapUtils;
import com.iwhalecloud.bss.kite.cucc.service.custview.userinfo.UserAttrSupplier;
import com.iwhalecloud.bss.kite.dataservice.cache.AttrValueCache;
import com.iwhalecloud.bss.kite.dataservice.entity.AttrValue;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * 12 缴费周期 FEE_CYCLE 110SPW400047存在
 */
@Service
@UserAttrSupplier(attrField = "ORD10233")
public class FeeCycleSupplier extends AbstractUserAttrSupplier {

    @Override
    public String getValue() {
        return KiteMapUtils.getString(userInfoContext.getUserInfo(), "FEE_CYCLE");
    }

    @Override
    public String getValueDesc() {
        String feeCycleVal = getValue();
        return Optional.ofNullable(AttrValueCache.getAttrValue("2020111102", feeCycleVal))
            .map(AttrValue::getAttrValueName).orElse(feeCycleVal);
    }
}
